<template>
	<view class="cttit">
		<text>捐赠记录</text>
		<view class=""></view>
	</view>


	<view class="listbg" >
		<view class="listitem" v-for="(item,index) in list" :key="index">
			<text class="names">{{item.createName}}</text>
			<view class="money"><text>{{item.price}}</text> 捐赠</view>
			<view class="time">
				<view class="">捐赠时间</view> <text>{{item.createTime}}</text>
			</view>
			<view class="time">
				<view class="">捐赠原因</view> <text>{{item.reason || '无'}}</text>
			</view>
		</view>
	</view>

	<up-loadmore lineColor="#ccc" line :status="status" />
</template>




<script setup>
	import {
		ref,
		onMounted
	} from 'vue';
	import { donateList } from "@/api/ancestra.js"
	import {
		onLoad,
		onReachBottom
	} from '@dcloudio/uni-app';

	onReachBottom(() => {
		page.value++
		getList()
	})
	onLoad((e) => {	
		getList()	
	})

	let status=ref('')
	let list = ref([])
	let page=ref(1)
	
	function getList() {
		
		let data = {
			pageSize: 10,
			pageNum: page.value,
		}
		status.value='loading'
		
		donateList(data).then(res => {
			status.value='nomore'
			if (page.value == 1) {
				list.value = res.rows
			} else {
				if (res.rows.length == 0) {
					page.value--
				} else {
					list.value = [...list.value, ...res.rows]
				}
			}
		})

	}


</script>






<style lang="scss">
	.cttit {
		margin-top: 36rpx;
		margin-left: 30rpx;
		position: relative;
		display: flex;
		flex-direction: column;

		&>text {
			font-family: PingFang-SC, PingFang-SC;
			font-weight: bold;
			font-size: 32rpx;
			color: #111111;
			line-height: 24rpx;
			position: relative;
			z-index: 10;
		}

		view {
			width: 130rpx;
			height: 16rpx;
			border-radius: 20rpx;
			background: #C7A46F;
			position: absolute;
			bottom: -6rpx;
		}
	}

	.listbg {

		width: 100%;
		overflow: hidden;

		.listitem {
			box-sizing: border-box;
			padding: 30rpx;
			margin-top: 24rpx;
			width: 690rpx;
			overflow: hidden;
			margin-left: 30rpx;
			background: #ffffff;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			padding-bottom: 40rpx;

			.names {
				width: 100%;
				text-align: center;
				font-family: PingFang-SC, PingFang-SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #333333;
				display: block;
				margin-top: 10rpx;
			}

			.money {
				width: 100%;
				display: flex;
				justify-content: center;
				align-items: center;
				font-family: PingFang-SC, PingFang-SC;
				font-weight: 500;
				font-size: 22rpx;
				color: #777777;
				margin-top: 4rpx;
				margin-bottom: 20rpx;

				text {
					font-family: PingFang-SC, PingFang-SC;
					font-weight: bold;
					font-size: 60rpx;
					color: #A9070C;
				}
			}

			.time {
				display: flex;
				font-family: PingFang-SC, PingFang-SC;
				font-weight: 500;
				font-size: 26rpx;
				color: #999999;
				margin-top: 20rpx;

				view {
					width: 180rpx;
					// background: #333333;
				}

				text {
					font-family: PingFang-SC, PingFang-SC;
					font-weight: 500;
					font-size: 26rpx;
					color: #111111;
					display: block;
					flex: 1;
					// margin-left: 80rpx;
				}
			}

			// <view class="listitem">
			// 	<text class="names">捐赠人姓名</text>
			// 	<view class="money"><text>2000.00</text> 捐赠</view>
			// 	<view class="time">捐赠时间 <text>2024-06-14 12:22:22</text> </view>
			// 	<view class="reson">捐赠原因 <text>对家族的认可支持</text> </view>
			// </view>

		}
	}
</style>